Skip to content

Preserve timestamps across renames#541

Open
adiel-mittmann wants to merge 1 commit intovgough:masterfrom
adiel-mittmann:master
Open

Preserve timestamps across renames#541
adiel-mittmann wants to merge 1 commit intovgough:masterfrom
adiel-mittmann:master

Conversation

@adiel-mittmann
Copy link

I'm using encfs 1.9.5.

When a directory is moved, modification times are only preserved for files. Here are two directories and a file:

[root@darkstar kth]# ls -laR a
a:
total 12
drwxr-xr-x 3 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Dec 20 13:30 ..
drwxr-xr-x 2 root root 4096 Oct  2  2015 b

a/b:
total 8
drwxr-xr-x 2 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Oct  2  2015 ..
-rw-r--r-- 1 root root    0 Oct  2  2015 c

If I copy the directory, times are preserved:

[root@darkstar kth]# cp -a a a.cp
[root@darkstar kth]# ls -laR a.cp
a.cp:
total 12
drwxr-xr-x 3 root root 4096 Oct  2  2015 .
drwxr-xr-x 4 root root 4096 Dec 20 13:31 ..
drwxr-xr-x 2 root root 4096 Oct  2  2015 b

a.cp/b:
total 8
drwxr-xr-x 2 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Oct  2  2015 ..
-rw-r--r-- 1 root root    0 Oct  2  2015 c

But once I use mv, times are lost:

[root@darkstar kth]# mv a.cp a.mv
[root@darkstar kth]# ls -laR a.mv
a.mv:
total 12
drwxr-xr-x 3 root root 4096 Dec 20 13:31 .
drwxr-xr-x 4 root root 4096 Dec 20 13:31 ..
drwxr-xr-x 2 root root 4096 Dec 20 13:31 b

a.mv/b:
total 12
drwxr-xr-x 2 root root 4096 Dec 20 13:31 .
drwxr-xr-x 3 root root 4096 Dec 20 13:31 ..
-rw-r--r-- 1 root root    0 Oct  2  2015 c

And the only time that was preserved, for file a/b/c, has now been truncated:

[root@darkstar kth]# stat a/b/c | grep Modify
Modify: 2015-10-02 10:44:40.960546000 -0300
[root@darkstar kth]# stat a.mv/b/c | grep Modify
Modify: 2015-10-02 10:44:40.000000000 -0300

While encfs does try to preserve timestamps, it does so by reading them too late in the process, when they have already been changed by previous operations.

This is the result with the patch applied:

[root@ouzo kth]# ls -laR a
a:
total 12
drwxr-xr-x 3 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Dec 20 13:58 ..
drwxr-xr-x 2 root root 4096 Oct  2  2015 b

a/b:
total 8
drwxr-xr-x 2 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Oct  2  2015 ..
-rw-r--r-- 1 root root    0 Oct  2  2015 c
[root@ouzo kth]# cp -a a a.cp
[root@ouzo kth]# ls -laR a.cp
a.cp:
total 12
drwxr-xr-x 3 root root 4096 Oct  2  2015 .
drwxr-xr-x 4 root root 4096 Dec 20 13:58 ..
drwxr-xr-x 2 root root 4096 Oct  2  2015 b

a.cp/b:
total 8
drwxr-xr-x 2 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Oct  2  2015 ..
-rw-r--r-- 1 root root    0 Oct  2  2015 c
[root@ouzo kth]# mv a.cp a.mv
[root@ouzo kth]# ls -laR a.mv
a.mv:
total 12
drwxr-xr-x 3 root root 4096 Oct  2  2015 .
drwxr-xr-x 4 root root 4096 Dec 20 13:58 ..
drwxr-xr-x 2 root root 4096 Oct  2  2015 b

a.mv/b:
total 12
drwxr-xr-x 2 root root 4096 Oct  2  2015 .
drwxr-xr-x 3 root root 4096 Oct  2  2015 ..
-rw-r--r-- 1 root root    0 Oct  2  2015 c
[root@ouzo kth]# stat a/b/c | grep Modify
Modify: 2015-10-02 10:44:40.960546225 -0300
[root@ouzo kth]# stat a.mv/b/c | grep Modify
Modify: 2015-10-02 10:44:40.960546225 -0300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant